<?php require_once("includes/initializeSession.php"); ?>
<?php
if (!isset($_SESSION['person_number'])) {
    header('Location: agentLogin.php');
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html>  
    <title>ר.א צ'ק אין - פתרונות ביטוח</title>
    <head>
<?php require_once("includes/cssAndJs.php"); ?>

                    <script type="text/javascript">
                        //style="vertical-align:top"

                        $(document).ready(function() {

                          


                                    $("#manuimList").jqGrid({
                                        url: "gridFunctions/manuimActions.php",
                                        editurl: "gridFunctions/manuimActions.php",
                                        direction: 'rtl',
                                        async: false,
                                        datatype: 'json',
                                        pager: '#manuimPager',
                                        colNames: ['מספר שורה', 'מספר מנוי', 'תאריך אסמכתא', 'מצב', 'סוכן', 'לקוח', 'מתאריך', 'עד תאריך', 'סוג רכב', 'קוד דגם', 'מס רישוי', 'שנת ייצור', 'סוג מנוי', 'מחיר מנוי', 'אמצעי תשלום', 'עמלת סוכן', 'ע"ח עמלת סוכן', 'סה"כ לתשלום', 'שולם?', 'אחרון', 'תאריך עמלה'],
                                        colModel: [
                                            {name: 'manuy_row', hidden: true, index: 'manuy_row', width: 60, editable: true, align: 'right', editoptions: {readonly: "readonly"}},
                                            {name: 'manuy_number', index: 'manuy_number', width: 80, editable: true, align: 'right', editoptions: {readonly: "readonly"}},
                                            {name: 'create_2', index: 'create_2', width: 100, editable: true, align: 'right', editoptions: {readonly: "readonly"}},
                                            {name: 'state', index: 'state', width: 60, editable: true, align: 'right', editoptions: {readonly: "readonly"}},
                                            {name: 'agent_person_number', index: 'agent_person_number', width: 60, editable: true, align: 'right', editoptions: {readonly: "readonly"}},
                                            {name: 'person_number', index: 'person_number', width: 120, editable: true, align: 'right', editoptions: {readonly: "readonly"}},
                                            {name: 'from_2', index: 'from_2', width: 110, editable: true, align: 'right'},
                                            {name: 'until', index: 'until', width: 110, editable: true, align: 'right'},
                                            {name: 'manufacturer', index: 'manufacturer', width: 70, editable: true, align: 'right'},
                                            {name: 'model', index: 'model', width: 70, editable: true, align: 'right'},
                                            {name: 'license_plate', index: 'license_plate', width: 80, editable: true, align: 'right'},
                                            {name: 'production_year', index: 'production_year', width: 60, editable: true, align: 'right'},
                                            {name: 'product_desc', index: 'product_desc', width: 80, editable: true, edittype: "select"},
                                            {name: 'product_price', editoptions: {readonly: "readonly"}, index: 'product_price', width: 80, editable: true, align: 'right'},
                                            {name: 'paymen_type', index: 'paymen_type', width: 70, editable: true, align: 'right'},
                                            {name: 'agent_commission', index: 'agent_commission', width: 70, editable: true, align: 'right', editoptions: {readonly: "readonly"}},
                                            {name: 'from_agent_commission', index: 'from_agent_commission', width: 70, editable: true, align: 'right', edittype: 'checkbox', formatter: "checkbox", editoptions: {value: "1:0"}},
                                            {name: 'total_payment', index: 'total_payment', width: 60, editable: true, align: 'right'},
                                            {name: 'shulam', index: 'shulam', width: 60, editable: true, align: 'right', edittype: 'checkbox', formatoptions: {disabled: true}, formatter: "checkbox", editoptions: {value: "1:0"}},
                                            {name: 'last', hidden: true, index: 'last', width: 60, editable: true, align: 'right', edittype: 'checkbox', formatter: "checkbox", editoptions: {value: "1:0"}},
                                            {name: 'agentAmlaDate', index: 'agentAmlaDate', width: 110, editable: true, align: 'right'}
                                            ],
                                        rowNum: 20,
                                        rowList: [5, 10, 20, 50],
                                        sortname: 'person_number',
                                        sortorder: "desc",
                                        mtype: "POST",
                                        //loadonce: true,
                                        postData: {oper: 'viewManuimof15DaysPast'},
                                        viewrecords: true,
                                        imgpath: '../../Scripts/css/Aristo/images',
                                        //autowidth: true,
                                        height: "100%"
                                    }); // -- end of   $("#list").jqGrid({
                                        //----------------- end manuim jqgrid

                                    $("#manuimList").jqGrid('navGrid', '#manuimPager', {edit: false, add: false, del: false,refresh: true, search: false}).navButtonAdd('#manuimPager', {
                                        caption: "ביטול",
                                        id: "cancelBTN",
                                        buttonicon: "ui-icon-add",
                                        onClickButton: function() {

                                            if (!getSelectedCellManuim15("person_number"))
                                            {
                                                alert("אתה חייב לבחור מנוי שאותו ברצונך לבטל");
                                            }
                                            else if (getSelectedCellManuim15("state") != "פעיל")
                                            {
                                                alert("אפשר לבטל רק מנוי פעיל");
                                            }
                                            else if (getSelectedCellManuim15("state") == "פעיל")
                                            {

                                               
                                                openManuimGridDialog(); // לא מעניין אותנו לשלוח את החלק שבוזבז

                                                $.ajax({url: 'gridFunctions/manuimActions.php', // הוצאת התאריך היצירה הראשוני
                                                    data: {oper: 'getFirstCreateDate', manuy_number: getSelectedCellManuim15("manuy_number")},
                                                    type: 'post',
                                                    success: function(output)
                                                    {
                                                        if (Date.today().compareTo(Date.parse(output).add(15).day()) === -1)
                                                        { 
                                                           jqgridFormMassage("לא עברו 15 ימים מ " + output + " ולכן המנוי מתבטל ללא תשלום");
                                                            $("#total_payment").val(parseInt(getSelectedCellManuim15("total_payment")) * (-1));
                                                            $("#agent_commission").val(parseInt(getSelectedCellManuim15("agent_commission")) * (-1));
                                                        }
                                                        else
                                                        {
                                                         
                                                        var moneyWaste= getMoneyWaste();
                                                        var manuyMoneyWaste = moneyWaste['manuyMoneyWaste']; //החלק שבוזבז על מנת לדעת כמה נשאר
                                                        var agentAmlotMoneyWaste = moneyWaste['agentAmlotMoneyWaste']; //החלק שבוזבז מהעמלה על מנת לדעת כמה נשאר
                                                       
                                                        var returnMoneyOnManuy =(parseInt(getSelectedCellManuim15("total_payment")) - manuyMoneyWaste)* (-1);
                                                        var returnMoneyOnAmla =(parseInt(getSelectedCellManuim15("agent_commission")) - agentAmlotMoneyWaste)* (-1);
                                                        jqgridFormMassage("עברו 15 ימים ולכן הלקוח נדרש לשלם את החלק היחסי מהתקופה שעברה");
                                                        $("#total_payment").val(returnMoneyOnManuy);
                                                        $("#agent_commission").val(returnMoneyOnAmla);   
                                                    }
                                                    }
                                                });	//end og ajax call

                                                $("#state").val("מבוטל");
                                                disableAllManuiamFieldsPutToday();
                                            }
                                        },
                                        position: "last"
                                    });
                                    $('#manuimList').jqGrid('filterToolbar', {searchOnEnter: true, enableClear: false,afterSearch: getIncomesAndAmlotPerAgent
                                    });
                                    
                                    
                                    
                                    
                                    
                                    $("#manuimList45").jqGrid({
                                        url: "gridFunctions/manuimActions.php",
                                        direction: 'rtl',
                                        async: false,
                                        datatype: 'json',
                                        pager: '#manuimPager45',
                                        colNames: ['מספר שורה', 'מספר מנוי', 'תאריך אסמכתא', 'מצב', 'סוכן', 'לקוח', 'מתאריך', 'עד תאריך', 'סוג רכב', 'קוד דגם', 'מס רישוי', 'שנת ייצור', 'סוג מנוי', 'מחיר מנוי', 'אמצעי תשלום', 'עמלת סוכן', 'ע"ח עמלת סוכן', 'סה"כ לתשלום', 'שולם?', 'אחרון', 'תאריך עמלה'],
                                        colModel: [
                                            {name: 'manuy_row', hidden: true, index: 'manuy_row', width: 60, editable: true, align: 'right', editoptions: {readonly: "readonly"}},
                                            {name: 'manuy_number', index: 'manuy_number', width: 80, editable: true, align: 'right', editoptions: {readonly: "readonly"}},
                                            {name: 'create_2', index: 'create_2', width: 100, editable: true, align: 'right', editoptions: {readonly: "readonly"}},
                                            {name: 'state', index: 'state', width: 60, editable: true, align: 'right', editoptions: {readonly: "readonly"}},
                                            {name: 'agent_person_number', index: 'agent_person_number', width: 60, editable: true, align: 'right', editoptions: {readonly: "readonly"}},
                                            {name: 'person_number', index: 'person_number', width: 120, editable: true, align: 'right', editoptions: {readonly: "readonly"}},
                                            {name: 'from_2', index: 'from_2', width: 110, editable: true, align: 'right'},
                                            {name: 'until', index: 'until', width: 110, editable: true, align: 'right'},
                                            {name: 'manufacturer', index: 'manufacturer', width: 70, editable: true, align: 'right'},
                                            {name: 'model', index: 'model', width: 70, editable: true, align: 'right'},
                                            {name: 'license_plate', index: 'license_plate', width: 80, editable: true, align: 'right'},
                                            {name: 'production_year', index: 'production_year', width: 60, editable: true, align: 'right'},
                                            {name: 'product_desc', index: 'product_desc', width: 80, editable: true, edittype: "select"},
                                            {name: 'product_price', editoptions: {readonly: "readonly"}, index: 'product_price', width: 80, editable: true, align: 'right'},
                                            {name: 'paymen_type', index: 'paymen_type', width: 70, editable: true, align: 'right'},
                                            {name: 'agent_commission', index: 'agent_commission', width: 70, editable: true, align: 'right', editoptions: {readonly: "readonly"}},
                                            {name: 'from_agent_commission', index: 'from_agent_commission', width: 70, editable: true, align: 'right', edittype: 'checkbox', formatter: "checkbox", editoptions: {value: "1:0"}},
                                            {name: 'total_payment', index: 'total_payment', width: 60, editable: true, align: 'right'},
                                            {name: 'shulam', index: 'shulam', width: 60, editable: true, align: 'right', edittype: 'checkbox', formatoptions: {disabled: true}, formatter: "checkbox", editoptions: {value: "1:0"}},
                                            {name: 'last', hidden: true, index: 'last', width: 60, editable: true, align: 'right', edittype: 'checkbox', formatter: "checkbox", editoptions: {value: "1:0"}},
                                            {name: 'agentAmlaDate', index: 'agentAmlaDate', width: 110, editable: true, align: 'right'}
                                            ],
                                        rowNum: 20,
                                        rowList: [5, 10, 20, 50],
                                        sortname: 'person_number',
                                        sortorder: "desc",
                                        mtype: "POST",
                                        //loadonce: true,
                                        postData: {oper: 'viewManuimof45DaysPast'},
                                        viewrecords: true,
                                        imgpath: '../../Scripts/css/Aristo/images',
                                        //autowidth: true,
                                        height: "100%"
                                    }); // -- end of   $("#list").jqGrid({
                                        //----------------- end manuim jqgrid

                                    $("#manuimList45").jqGrid('navGrid', '#manuimPager45', {edit: false, add: false, del: false,refresh: true, search: false}).navButtonAdd('#manuimPager45', {
                                        caption: "ביטול",
                                        id: "cancelBTN",
                                        buttonicon: "ui-icon-add",
                                        onClickButton: function() {

                                            if (!getSelectedCellManuim45("person_number"))
                                            {
                                                alert("אתה חייב לבחור מנוי שאותו ברצונך לבטל");
                                            }
                                            else if (getSelectedCellManuim45("state") != "פעיל")
                                            {
                                                alert("אפשר לבטל רק מנוי פעיל");
                                            }
                                            else if (getSelectedCellManuim45("state") == "פעיל")
                                            {

                                               
                                                openManuimGridDialog(); // לא מעניין אותנו לשלוח את החלק שבוזבז

                                                $.ajax({url: 'gridFunctions/manuimActions.php', // הוצאת התאריך היצירה הראשוני
                                                    data: {oper: 'getFirstCreateDate', manuy_number: getSelectedCellManuim45("manuy_number")},
                                                    type: 'post',
                                                    success: function(output)
                                                    {
                                                        if (Date.today().compareTo(Date.parse(output).add(15).day()) === -1)
                                                        { 
                                                           jqgridFormMassage("לא עברו 15 ימים מ " + output + " ולכן המנוי מתבטל ללא תשלום");
                                                            $("#total_payment").val(parseInt(getSelectedCellManuim45("total_payment")) * (-1));
                                                            $("#agent_commission").val(parseInt(getSelectedCellManuim45("agent_commission")) * (-1));
                                                        }
                                                        else
                                                        {
                                                         
                                                        var moneyWaste= getMoneyWaste();
                                                        var manuyMoneyWaste = moneyWaste['manuyMoneyWaste']; //החלק שבוזבז על מנת לדעת כמה נשאר
                                                        var agentAmlotMoneyWaste = moneyWaste['agentAmlotMoneyWaste']; //החלק שבוזבז מהעמלה על מנת לדעת כמה נשאר
                                                       
                                                        var returnMoneyOnManuy =(parseInt(getSelectedCellManuim45("total_payment")) - manuyMoneyWaste)* (-1);
                                                        var returnMoneyOnAmla =(parseInt(getSelectedCellManuim45("agent_commission")) - agentAmlotMoneyWaste)* (-1);
                                                        jqgridFormMassage("עברו 15 ימים ולכן הלקוח נדרש לשלם את החלק היחסי מהתקופה שעברה");
                                                        $("#total_payment").val(returnMoneyOnManuy);
                                                        $("#agent_commission").val(returnMoneyOnAmla);   
                                                    }
                                                    }
                                                });	//end og ajax call

                                                $("#state").val("מבוטל");
                                                disableAllManuiamFieldsPutToday();
                                            }
                                        },
                                        position: "last"
                                    });
                                    $('#manuimList45').jqGrid('filterToolbar', {searchOnEnter: true, enableClear: false,afterSearch: getIncomesAndAmlotPerAgent
                                    });
                                    
                                    
                                    
                                    
                                        $("#manuimList60").jqGrid({
                                        url: "gridFunctions/manuimActions.php",
                                        direction: 'rtl',
                                        async: false,
                                        datatype: 'json',
                                        pager: '#manuimPager60',
                                        colNames: ['מספר שורה', 'מספר מנוי', 'תאריך אסמכתא', 'מצב', 'סוכן', 'לקוח', 'מתאריך', 'עד תאריך', 'סוג רכב', 'קוד דגם', 'מס רישוי', 'שנת ייצור', 'סוג מנוי', 'מחיר מנוי', 'אמצעי תשלום', 'עמלת סוכן', 'ע"ח עמלת סוכן', 'סה"כ לתשלום', 'שולם?', 'אחרון', 'תאריך עמלה'],
                                        colModel: [
                                            {name: 'manuy_row', hidden: true, index: 'manuy_row', width: 60, editable: true, align: 'right', editoptions: {readonly: "readonly"}},
                                            {name: 'manuy_number', index: 'manuy_number', width: 80, editable: true, align: 'right', editoptions: {readonly: "readonly"}},
                                            {name: 'create_2', index: 'create_2', width: 100, editable: true, align: 'right', editoptions: {readonly: "readonly"}},
                                            {name: 'state', index: 'state', width: 60, editable: true, align: 'right', editoptions: {readonly: "readonly"}},
                                            {name: 'agent_person_number', index: 'agent_person_number', width: 60, editable: true, align: 'right', editoptions: {readonly: "readonly"}},
                                            {name: 'person_number', index: 'person_number', width: 120, editable: true, align: 'right', editoptions: {readonly: "readonly"}},
                                            {name: 'from_2', index: 'from_2', width: 110, editable: true, align: 'right'},
                                            {name: 'until', index: 'until', width: 110, editable: true, align: 'right'},
                                            {name: 'manufacturer', index: 'manufacturer', width: 70, editable: true, align: 'right'},
                                            {name: 'model', index: 'model', width: 70, editable: true, align: 'right'},
                                            {name: 'license_plate', index: 'license_plate', width: 80, editable: true, align: 'right'},
                                            {name: 'production_year', index: 'production_year', width: 60, editable: true, align: 'right'},
                                            {name: 'product_desc', index: 'product_desc', width: 80, editable: true, edittype: "select"},
                                            {name: 'product_price', editoptions: {readonly: "readonly"}, index: 'product_price', width: 80, editable: true, align: 'right'},
                                            {name: 'paymen_type', index: 'paymen_type', width: 70, editable: true, align: 'right'},
                                            {name: 'agent_commission', index: 'agent_commission', width: 70, editable: true, align: 'right', editoptions: {readonly: "readonly"}},
                                            {name: 'from_agent_commission', index: 'from_agent_commission', width: 70, editable: true, align: 'right', edittype: 'checkbox', formatter: "checkbox", editoptions: {value: "1:0"}},
                                            {name: 'total_payment', index: 'total_payment', width: 60, editable: true, align: 'right'},
                                            {name: 'shulam', index: 'shulam', width: 60, editable: true, align: 'right', edittype: 'checkbox', formatoptions: {disabled: true}, formatter: "checkbox", editoptions: {value: "1:0"}},
                                            {name: 'last', hidden: true, index: 'last', width: 60, editable: true, align: 'right', edittype: 'checkbox', formatter: "checkbox", editoptions: {value: "1:0"}},
                                            {name: 'agentAmlaDate', index: 'agentAmlaDate', width: 110, editable: true, align: 'right'}
                                            ],
                                        rowNum: 20,
                                        rowList: [5, 10, 20, 50],
                                        sortname: 'person_number',
                                        sortorder: "desc",
                                        mtype: "POST",
                                        //loadonce: true,
                                        postData: {oper: 'viewManuimof60DaysPast'},
                                        viewrecords: true,
                                        imgpath: '../../Scripts/css/Aristo/images',
                                        //autowidth: true,
                                        height: "100%"
                                    }); // -- end of   $("#list").jqGrid({
                                        //----------------- end manuim jqgrid

                                    $("#manuimList60").jqGrid('navGrid', '#manuimPager60', {edit: false, add: false, del: false,refresh: true, search: false}).navButtonAdd('#manuimPager60', {
                                        caption: "ביטול",
                                        id: "cancelBTN",
                                        buttonicon: "ui-icon-add",
                                        onClickButton: function() {

                                            if (!getSelectedCellManuim60("person_number"))
                                            {
                                                alert("אתה חייב לבחור מנוי שאותו ברצונך לבטל");
                                            }
                                            else if (getSelectedCellManuim60("state") != "פעיל")
                                            {
                                                alert("אפשר לבטל רק מנוי פעיל");
                                            }
                                            else if (getSelectedCellManuim60("state") == "פעיל")
                                            {

                                               
                                                openManuimGridDialog(); // לא מעניין אותנו לשלוח את החלק שבוזבז

                                                $.ajax({url: 'gridFunctions/manuimActions.php', // הוצאת התאריך היצירה הראשוני
                                                    data: {oper: 'getFirstCreateDate', manuy_number: getSelectedCellManuim60("manuy_number")},
                                                    type: 'post',
                                                    success: function(output)
                                                    {
                                                        if (Date.today().compareTo(Date.parse(output).add(15).day()) === -1)
                                                        { 
                                                           jqgridFormMassage("לא עברו 15 ימים מ " + output + " ולכן המנוי מתבטל ללא תשלום");
                                                            $("#total_payment").val(parseInt(getSelectedCellManuim60("total_payment")) * (-1));
                                                            $("#agent_commission").val(parseInt(getSelectedCellManuim60("agent_commission")) * (-1));
                                                        }
                                                        else
                                                        {
                                                         
                                                        var moneyWaste= getMoneyWaste();
                                                        var manuyMoneyWaste = moneyWaste['manuyMoneyWaste']; //החלק שבוזבז על מנת לדעת כמה נשאר
                                                        var agentAmlotMoneyWaste = moneyWaste['agentAmlotMoneyWaste']; //החלק שבוזבז מהעמלה על מנת לדעת כמה נשאר
                                                       
                                                        var returnMoneyOnManuy =(parseInt(getSelectedCellManuim60("total_payment")) - manuyMoneyWaste)* (-1);
                                                        var returnMoneyOnAmla =(parseInt(getSelectedCellManuim60("agent_commission")) - agentAmlotMoneyWaste)* (-1);
                                                        jqgridFormMassage("עברו 15 ימים ולכן הלקוח נדרש לשלם את החלק היחסי מהתקופה שעברה");
                                                        $("#total_payment").val(returnMoneyOnManuy);
                                                        $("#agent_commission").val(returnMoneyOnAmla);   
                                                    }
                                                    }
                                                });	//end og ajax call

                                                $("#state").val("מבוטל");
                                                disableAllManuiamFieldsPutToday();
                                            }
                                        },
                                        position: "last"
                                    });
                                    
                                    
                                    $('#manuimList60').jqGrid('filterToolbar', {searchOnEnter: true, enableClear: false,afterSearch: getIncomesAndAmlotPerAgent
                                    });



 //------------------------------------datepicker for manuim search
 
 
                                 
 
                                   var  checkInDateInManuimSearch = $($("[id=gs_from_2]")[0]);
                                       var     checkOutDateInManuimSearch = $($("[id=gs_until]")[0]);
                                       
                                       
                                            checkInDateInManuimSearch.datepicker({
                                                dateFormat: 'yy-mm-dd',
                                            });

                                            checkOutDateInManuimSearch.datepicker({
                                                dateFormat: 'yy-mm-dd',
                                            });
                                            checkInDateInManuimSearch.datepicker('setDate', new Date().add(-1).year());
                                            checkOutDateInManuimSearch.datepicker('setDate', new Date().add(1).year());
                                            
                                            
                                        

                                    //-----------------------------------
                                   getIncomesAndAmlotPerAgent();
                                    
                                    
                                });// -- end of  $(document).ready(function ()
                                  
                                function getSelectedCellManuim(str)
                                {
                                    var grid = jQuery('#manuimList');
                                    var sel_id = grid.jqGrid('getGridParam', 'selrow');
                                    var myCellData = grid.jqGrid('getCell', sel_id, str);
                                    return myCellData;
                                }


                                function getIncomesAndAmlotPerAgent()
                                {
                                        $.ajax({url: 'gridFunctions/manuimActions.php',
                                        data: {oper: 'getIncomesAndAmlotPerAgent', manuy_number:$($("[id=gs_manuy_number]")[0]).val(),
create_2:$($("[id=gs_create_2]")[0]).val(),
state:$($("[id=gs_state]")[0]).val(),
agent_person_number:$($("[id=gs_agent_person_number]")[0]).val(),
person_number:$($("[id=gs_person_number]")[0]).val(),
from_2:$($("[id=gs_from_2]")[0]).val(),
until:$($("[id=gs_until]")[0]).val(),
manufacturer:$($("[id=gs_manufacturer]")[0]).val(),
model:$($("[id=gs_model]")[0]).val(),
license_plate:$($("[id=gs_license_plate]")[0]).val(),
production_year:$($("[id=gs_production_year]")[0]).val(),
product_desc:$($("[id=gs_product_desc]")[0]).val(),
product_price:$($("[id=gs_product_price]")[0]).val(),
paymen_type:$($("[id=gs_paymen_type]")[0]).val(),
agent_commission:$($("[id=gs_agent_commission]")[0]).val(),
from_agent_commission:$($("[id=gs_from_agent_commission]")[0]).val(),
total_payment:$($("[id=gs_total_payment]")[0]).val(),
shulam:$($("[id=gs_shulam]")[0]).val(),
agentAmlaDate:$($("[id=gs_agentAmlaDate]")[0]).val()},
                                        type: 'post',
                                        success: function(output)
                                        {
                                            //       console.log("output " + output);
                                            //    firstDate=output;
                                            // console.log(output)
                                        
                                            var report = eval('(' + output + ')')[0];
                                            $('#headerIncomes').text("הכנסות לתקופה : " + report.sum_total_payment);
                                    $('#headerAmlot').text("עמלות לתקופה : " + report.sum_agent_commission);
                                           // return output.responseText;

                                        }
                                        
                                    });	//end og ajax call
                                    //   console.log("firstDate " + firstDate);
                                    return true;
                             
                                }             //  end getIncomesAndAmlotPerAgent
                    
                                
                                function getSelectedCellManuim15(str)
                                {
                                    var grid = jQuery('#manuimList');
                                    var sel_id = grid.jqGrid('getGridParam', 'selrow');
                                    var myCellData = grid.jqGrid('getCell', sel_id, str);
                                    return myCellData;
                                }
                                function getSelectedCellManuim45(str)
                                {
                                    var grid = jQuery('#manuimList45');
                                    var sel_id = grid.jqGrid('getGridParam', 'selrow');
                                    var myCellData = grid.jqGrid('getCell', sel_id, str);
                                    return myCellData;
                                }
                                function getSelectedCellManuim60(str)
                                {
                                    var grid = jQuery('#manuimList60');
                                    var sel_id = grid.jqGrid('getGridParam', 'selrow');
                                    var myCellData = grid.jqGrid('getCell', sel_id, str);
                                    return myCellData;
                                }
                                
                                function openManuimGridDialog(manuyMoneyWaste,agentAmlotMoneyWaste)
                                {
                                    if(manuyMoneyWaste== 'undefined') manuyMoneyWaste=false;
                                    if(agentAmlotMoneyWaste== 'undefined') agentAmlotMoneyWaste=false;

                                    var grid = jQuery("#manuimList");
                                    var rowKey = grid.getGridParam("selrow");
                                    grid.editGridRow(rowKey, {reloadAfterSubmit: true, closeAfterEdit: true, closeAfterAdd: true, recreateForm: true, width: 450, onclickSubmit: function(rp_ge, postdata)
                                        {
                                            return {product_desc: $("#product_desc option:selected").text(), manuy_row: getSelectedCellManuim('manuy_row'), oper: "add",manuyMoneyWaste: manuyMoneyWaste, agentAmlotMoneyWaste: agentAmlotMoneyWaste, totalPaymentBefore: getSelectedCellManuim("total_payment"), totalComistionBefore: getSelectedCellManuim("agent_commission")};
                                        }});
                                    $(".navButton").hide();

                                }
                                  function disableAllManuiamFieldsPutToday()
                                {
                                    $("#from_2").val(Date.today().toString('yyyy-MM-dd'));
                                    $("#from_2").attr("disabled", true)
                                    $("#until").attr("disabled", true)
                                    $("#manufacturer").attr("disabled", true)
                                    $("#model").attr("disabled", true)
                                    $("#license_plate").attr("disabled", true)
                                    $("#production_year").attr("disabled", true)
                                    $("#total_payment").attr("disabled", true)
                                    $("#product_desc").attr("disabled", true)
                                    $("#paymen_type").attr("disabled", true)
                                    $("#from_agent_commission").attr("disabled", true);
                                    $("#shulam").attr("disabled", true);

                                }
                                  function getMoneyWaste()
                                {
                                 var a = Date.today();
                                var b = Date.parse(getSelectedCellManuim("from_2"));
                                var c = Date.parse(getSelectedCellManuim("until"));
                                var manuyDuration = new TimeSpan(c - b);
                                var daysPast = new TimeSpan(a - b);
                                var manuyMoneyWaste= parseInt(getSelectedCellManuim("total_payment")) / (manuyDuration.days) * (daysPast.days);
                                var agentAmlotMoneyWaste= parseInt(getSelectedCellManuim("agent_commission")) / (manuyDuration.days) * (daysPast.days);
                                 return {manuyMoneyWaste:manuyMoneyWaste,agentAmlotMoneyWaste:agentAmlotMoneyWaste}
                                }
                                function jqgridFormMassage(str)
                                {
                                    $(".tinfo").show();
                                    $(".topinfo").addClass("ui-state-highlight ui-corner-all");
                                    $(".topinfo").html(str);
                                }


                    </script>
                    </head>
                    <body dir="rtl"  style="padding:0px; margin:0px;">
                        <div id="main">
                            <?php include("header.php"); ?>
                            
                            <h1 id="headerIncomes" style="display: none">aa</h1> 
                            <h1 id="headerAmlot" style="display: none">bb</h1> 

                 
                            <h1>למנויים הבאים עברו 15 יום מתאריך אסמכתא, האם לבטל ? (ללא תשלום)</h1>  
                            <div id="lc">
                                <table id="manuimList" class="scroll" cellpadding="0" cellspacing="0"></table>
                                <div id="manuimPager" class="scroll" style="text-align: center;"> </div>
                            </div>
                            </br>
                            
                            
                            <h1>למנויים הבאים עברו 45 יום מתאריך אסמכתא</h1>  
                            <div id="lc">
                                <table id="manuimList45" class="scroll" cellpadding="0" cellspacing="0"></table>
                                <div id="manuimPager45" class="scroll" style="text-align: center;"> </div>
                            </div>
                            </br>
                            
                                <h1>למנויים הבאים עברו 60 יום מתאריך אסמכתא, הם כבר לא תקפים ? (נדרש תשלום)</h1>  
                            <div id="lc">
                                <table id="manuimList60" class="scroll" cellpadding="0" cellspacing="0"></table>
                                <div id="manuimPager60" class="scroll" style="text-align: center;"> </div>
                            </div>
                            </br>
                           


                            <?php include("footer.php"); ?>	
                        </div>

                    </body>
                    </html>